<template>
  <div>
    <div>
      {{ isRun ? "已启动" : "未启动" }}
    </div>
    <el-button size="mini" @click="sendCMD('start')">启动</el-button>
    <el-button size="mini" @click="sendCMD('stop')">停止</el-button>
    <el-button size="mini" @click="sendCMD('reload')">刷新配置</el-button>
    <el-button size="mini" @click="installConfig">安装配置</el-button>
  </div>
</template>

<script>
import { reactive, toRefs, onBeforeMount, onMounted, getCurrentInstance } from "vue";
export default {
  name: "",
  setup() {
    const instance = getCurrentInstance();
    const state = reactive({
      isRun: false,
    });
    onBeforeMount(() => {
      $.get("api/nginx/isRun").then((r) => {
        state.isRun = r.data;
      });
    });
    onMounted(() => {
      console.log("3.-组件挂载到页面之后执行-------onMounted");
    });
    return {
      ...toRefs(state),
      installConfig() {
        $.get("api/nginx/InstallConfig");
      },
      refLoad(cmd) {
        $.get("api/nginx/runCmd", {
          cmd,
        });
      },
    };
  },
};
</script>
